package com.maixy.dailydemo.bloom;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;

/**
 * @ClassName BloomTest
 * @Description TODO
 * @Date 2021/7/3 14:48
 * @Author maixingyu
 */
public class BloomTest {
    public static void main(String[] args) {
        //布隆过滤器只能判断一个数据一定不存在，不能判断一个数据一定存在
        //启动时初始化布隆过滤器，后面有新的数据再加入到布隆过滤器中
        BloomFilter<Integer> filterTest = BloomFilter.create(Funnels.integerFunnel(), 500, 0.01);
        filterTest.put(1);
        filterTest.put(2);
        filterTest.put(3);

        System.out.println((filterTest.mightContain(1)));
        System.out.println((filterTest.mightContain(2)));
        System.out.println((filterTest.mightContain(3)));
        System.out.println((filterTest.mightContain(100)));
    }
}
